/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __VGLVIEW_H__
#define __VGLVIEW_H__

#include "./vView.h"
#include "../../Macros/vMemoryMacros.h"

namespace Vendetta {
	/**
	 *	OpenGL based view class.
	 *	@see vView
	 */
	class  vGlView: public vView {
	public:

		vGlView();
		~vGlView();

		vVoid SetFrustum(const vVector3D &leftBottomNear, const vVector3D &rightTopFar);
		vVoid SetPerspective(const vReal FOVY, const vReal aspect, const vReal near, const vReal far);
		vVoid SetViewPort(const vInt &left, const vInt &bottom, const vInt &width, const vInt &height);
		vVoid SetDepthRange(const vReal near, const vReal far);
		vVoid SetOrtho(const vVector3D &leftBottomNear, const vVector3D &rightTopFar);

		vVoid LoadIdentity();
		vVoid LoadTranslate(const vVector3D &vector);
		vVoid LoadTranslate(const vVector2D &vector);
		vVoid LoadRotate(const vReal angle, const vVector3D &vector);
		vVoid LoadRotateZ(const vReal angle);
		vVoid LoadScale(const vVector3D &vector);
		vVoid LoadMatrix(const vMatrix4D &matrix);

		vVoid Translate(const vVector3D &vector);
		vVoid Translate(const vVector2D &vector);
		vVoid Translate(const vReal x, const vReal y);
		vVoid TranslateX(const vReal x);
		vVoid TranslateY(const vReal y);
		vVoid Rotate(const vReal angle, const vVector3D &vector);
		vVoid RotateZ(const vReal angle);
		vVoid RotateY(const vReal angle);
		vVoid RotateX(const vReal angle);
		vVoid Scale(const vVector3D &vector);
		vVoid MultMatrix(const vMatrix4D &matrix);

		vVoid LookAt(const vVector3D &eyeVertex, const vVector3D &tarVertex, const vVector3D &upVector);
		vVoid PushMatrix();
		vVoid PopMatrix();
		vVoid EnableOrtho();
		vVoid DisableOrtho();
		
		vVoid EnableScissors(const vRectangle& rectangle);
		vVoid DisableScissors();
		vVoid PushScissors(const vRectangle& rectangle);
		vVoid PopScissors();
		
		vVoid Project(const vVector3D &vertex, vVector2D &screenCoords);
		vVoid Unproject(vVector3D &vertex, const vVector2D &screenCoords);
		
		vVector3D Origin() const;
		vVector3D Angles() const;
		vVector2D Translation()const;
		vVoid ModelViewMatrix(vMatrix4D &matrix) const;
		vVoid ProjectionMatrix(vMatrix4D &matrix) const;

	};
}

#endif //__VGLVIEW_H__